{include file="public/header"}
<body>
	<div class="x-nav" style="margin-top: 10px;">
		<span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">案例管理</a>
        <a>
          <cite>案例列表</cite></a>
      </span>
		<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
			<i class="layui-icon" style="line-height:30px">ဂ</i></a>
	</div>
	<div class="x-body">
		<xblock>
			<!--<button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>-->
			<button class="layui-btn" onclick="x_admin_show('添加文章','{:url("news/add_")}','100%' ,'100%')"><i class="layui-icon"></i>添加案例</button>
			<span class="x-right" style="line-height:40px">共有数据：{$total}条</span>
		</xblock>
		<table class="layui-table">
			<thead>
				<tr>
					<th style="text-align:center;">ID</th>
					<th>标题</th>
					<th style="text-align:center;">案例分类</th>
					<th style="text-align:center;">浏览次数</th>
					<th style="text-align:center;">操作</th>
				</tr>
			</thead>
			<tbody>
				{volist name="list" id="vo"}
				<tr>
					<td style="text-align:center;">{$vo.id}</td>
					<td style="text-decoration: underline;"><a href="/preview/{$vo.id}.html"  target="_blank">{$vo.title}</a></td>
					<td style="text-align:center;">{$vo.case_class_name}</td>
					<td style="text-align:center;">{$vo.views}</td>
					<td class="td-manage" style="text-align:center;">
						<a title="预览"  href='/preview/{$vo.id}.html' target="_blank" 
							style="display: inline-block;width: calc(33.3% - 10px);text-align: center;text-decoration: underline;">
							预览
						</a>
						<a title="编辑" style="display: inline-block;width: calc(33.3% - 10px);text-align: center;text-decoration: underline;"
							onclick="x_admin_show('编辑文章','/edit_news/'+'{$vo.id}.html','100%' ,'100%')" href="javascript:;" style="margin:0 15px;">
							编辑
						</a>
						<a title="删除" style="display: inline-block;width: calc(33.3% - 10px);text-align: center;text-decoration: underline;"
							onclick="article_del(this,{$vo.id})" href="javascript:;">
							删除
						</a>
					</td>
				</tr>
				{/volist}
			</tbody>
		</table>
		<div class="page">
			<div>
				{$page}
			</div>
		</div>

	</div>
	{include file="public/base_js"}
	<script>
		/*监听更新操作*/
		window.addEventListener('storage', function (e) {
			console.log(e);
			if (e.key =='update_news_list') {
				window.location.reload(true);
			}
		}, false);
		/*文章-删除*/
		function article_del(obj, id) {
			console.log(id);
			layer.confirm('确认要删除吗？', function(index) {
				$.ajax({
					type: 'post',
					url:"{:url('news/delete_news')}",
					data: {
						id: id
					},
					success (e) {
						console.log(e);
						layer.msg('删除成功!', {
							icon: 1,
							time: 1000
						},function () {
							window.localStorage.setItem('update_news_list',new Date().getTime()); 
							window.location.reload(true);
						});
					}
				})
				
			});
		}
	</script>

</body>

</html>